﻿Imports System.Data.SqlClient

Public Class frmPedidos

    Dim variableconex As New SqlConnection(My.Settings.CITRA_ERPConnectionString)

    Private Sub frmPedidos_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        CargarDatos()
        SlidePanel5.BackColor = Color.Black
        slideNuevo.IsOpen = False
        SlidePanel2.IsOpen = False
        SlidePanel3.IsOpen = False
        SlidePanel5.IsOpen = False

    End Sub


    Public Sub CargarDatos()

        Dim DS As New DataSet
        Dim DA As New SqlDataAdapter("select ped.idPedido, alm.Nombre as Almacen, usu.Nombre as Usuario, ped.Fecha, ped.Estatus from Pedidos ped, almacenes alm, citragenerales.dbo.usuarios usu where ped.IDALMACEN=alm.IDALMACEN and ped.IDUSUARIO=usu.IdUsuario", variableconex)

        DA.Fill(DS)

        dgvMovimientosPedidos.DataSource = DS.Tables(0)

        dgvMovimientosPedidos.Columns(0).Width = 200
        dgvMovimientosPedidos.Columns(1).Width = 300
        dgvMovimientosPedidos.Columns(2).Width = 200
        dgvMovimientosPedidos.Columns(3).Width = 300
        dgvMovimientosPedidos.Columns(4).Width = 200



    End Sub


    Private Sub ButtonX1_Click(sender As Object, e As EventArgs) Handles ButtonX1.Click
        Close()
    End Sub

    Private Sub ButtonItem1_Click(sender As Object, e As EventArgs)
        frmNuevoPedido.ShowDialog()
    End Sub

    Private Sub dgvMovimientosPedidos_DoubleClick(sender As Object, e As EventArgs) Handles dgvMovimientosPedidos.DoubleClick
        sacarPedido()
    End Sub

    Public Sub sacarPedido()

        Dim fila As Integer
        fila = dgvMovimientosPedidos.CurrentCell.RowIndex
        Dim valor As Integer
        valor = dgvMovimientosPedidos.Rows(fila).Cells(0).Value.ToString()
        FrmDetallePedido.lblPedido.Text = valor.ToString
        FrmDetallePedido.MostrarDetallePedido(valor)
        FrmDetallePedido.Show()

    End Sub

    Private Sub btnAceptar_Click(sender As Object, e As EventArgs)

    End Sub

    Private Sub btnCancelar_Click(sender As Object, e As EventArgs)

    End Sub

    Private Sub ButtonItem2_Click(sender As Object, e As EventArgs)

    End Sub

    Private Sub ButtonItem8_Click(sender As Object, e As EventArgs) Handles ButtonItem8.Click
        frmNuevoPedido.Show()
    End Sub

    Private Sub ButtonItem47_Click(sender As Object, e As EventArgs) Handles ButtonItem47.Click
        SlidePanel2.IsOpen = True
    End Sub

    Private Sub ButtonItem43_Click(sender As Object, e As EventArgs) Handles ButtonItem43.Click
        SlidePanel2.IsOpen = False
    End Sub

    Private Sub ButtonItem44_Click(sender As Object, e As EventArgs) Handles ButtonItem44.Click
        SlidePanel3.IsOpen = False
    End Sub

    Private Sub ButtonItem51_Click(sender As Object, e As EventArgs) Handles ButtonItem51.Click
        SlidePanel3.IsOpen = True
    End Sub

    Private Sub ButtonItem16_Click(sender As Object, e As EventArgs) Handles ButtonItem16.Click
        SlidePanel5.IsOpen = False
    End Sub

    Private Sub ButtonItem64_Click(sender As Object, e As EventArgs) Handles ButtonItem64.Click, ButtonItem29.Click
        SlidePanel5.IsOpen = True
    End Sub

    Private Sub ButtonItem53_Click(sender As Object, e As EventArgs) Handles ButtonItem53.Click
        slideNuevo.IsOpen = True
    End Sub

    Private Sub btnCerrar_Click(sender As Object, e As EventArgs) Handles btnCerrar.Click
        slideNuevo.IsOpen = False
    End Sub
End Class